import axios from './axios'
const apiMall = 'http://223.4.68.227:8089/zlhw'

/*
* 整体接口管理
*/

/* --------------登录界面----------- */
//登录("userName":"xxzx","pwd":"18142006346")
const login = (params) => axios('post',apiMall +  '/userlogin',params);


/* --------------供应商设置界面----------- */
//获取供应商的列表
const getUser = (params) => axios('get',apiMall + '/userlist',params);
//新增、修改供应商("userId":"2","userName":"userName1","key":"key1","trueName":"trueName1","contactUser":"contactUser1","contactTel":"contactTel1")
const setUser = (params) => axios('post',apiMall + '/updateuser',params);
//根据ID 获取key("userId":"0")
const getKeyById = (params) => axios('post',apiMall + '/getuserkeybyid',params);


/* --------------白名单设置界面----------- */
//获取白名单
const getBip = (params) => axios('get',apiMall + '/getbip',params);
//设置白名单({"bip":"127.0.0.1,112.17.125.125,182.61.61.89"})
const setNewBip = (params) => axios('post',apiMall + '/setnewbip',params);


/* --------------栏目设置界面----------- */
//获取所有的栏目列表
const getColumnList = (params) => axios('get',apiMall + '/columnlist',params);
//根据ID获取栏目信息("cId":"1")
const getColumnById = (params) => axios('post',apiMall + '/columnbyid',params);
//新增修改栏目
// ("cId":"2","columnTitle":"columnTitle","columnSubTitle":"columnSubTitle","columnPic":"columnPic","outLink":"1","columnUrl":"columnUrl","appId":"appId","loadPage":"10","orderNo":"10","defaultCount":"10")
const setColumn = (params) => axios('post',apiMall + '/updatecolumn',params);


/* --------------文章列表界面----------- */
//获取文章列表("currIndex":"1","pageSize":"10","cId":"1","newsTitle":"标题","userId":"1","useState":"1")
const getZlhwList = (params) => axios('post',apiMall + '/getnewsinfolist',params);
//根据id获取文章("newsId":"1")
const getZlhwById = (params) => axios('post',apiMall + '/getnewsinfobyid',params);
//新增、修改文章
const setNewsInfo = (params) => axios('post',apiMall + '/updatenewsinfo',params);
//删除文章("newsId":"2")
const deleteNewsInfo = (params) => axios('post',apiMall + '/delnewsinfobyid',params);
//根据状态获取文章数量("useState":"2")
const getNewsByState = (params) => axios('post',apiMall + '/getnewsinfocountbystate',params);
//根据文章ID修改文章部分内容( "newsId":"10","useState":"1","orderNo":"0","isTop":"0")
const setListByNewsId = (params) => axios('post',apiMall + '/updatestateordernoistop',params);

/* --------------首页界面----------- */
//获取缓存状态Get
const getRedisState = (params) => axios('get' , 'http://223.4.68.227:8088/zlhw/redisState',params);
//更新数据
const upDataHome = (params) => axios('post' , 'http://223.4.68.227:8088/zlhw/redisClean',params);

export default {
  login,
  getUser,
  getBip,
  setNewBip,
  getKeyById,
  setUser,
  getColumnList,
  getColumnById,
  setColumn,
  getZlhwList,
  getZlhwById,
  setNewsInfo,
  deleteNewsInfo,
  getNewsByState,
  setListByNewsId,
  getRedisState,
  upDataHome
}
